/*
 *    Copyright (c) 2018-2025, idata All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the pig4cloud.com developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author: idata
 */
package com.quark.model.system.gen;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;

/**
 * @author 张高昌
 * @version 版本
 * @date 2022/01/15 18:38
 * @description: 数据源表
 */
@Data
@TableName("sys_datasource_conf")
@EqualsAndHashCode(callSuper = true)
public class SysDatasourceConf extends Model<SysDatasourceConf> {

    private static final long serialVersionUID = 1L;

    /**
     * 主键
     */
    @TableId(type = IdType.AUTO)
    private Integer id;

    /**
     * 名称
     */
    @NotBlank
    @Length(min = 2, max = 50)
    private String name;

    /**
     * 数据库类型
     */
    @NotBlank
    @Length(min = 2, max = 50)
    private String dsType;

    /**
     * 配置类型 （0 主机形式 | 1 url形式）
     */
    @NotNull
    @Min(value = 0, message = "最小值不能低于0")
    @Max(value = 1, message = "最大值不能大于1")
    private Integer confType;

    /**
     * 主机地址
     */
    private String host;

    /**
     * 端口
     */
    @NotNull
    @Min(value = 0, message = "最小值不能低于0")
    @Max(value = 65535, message = "最大值不能大于65535")
    private Integer port;

    /**
     * jdbc-url
     */
    private String url;

    /**
     * 实例
     */
    private String instance;

    /**
     * 数据库名称
     */
    private String dsName;

    /**
     * 用户名
     */
    @NotBlank
    @Length(min = 1, max = 64)
    private String username;

    /**
     * 密码
     */
    @NotBlank
    @Length(min = 2, max = 64)
    private String password;

    /**
     * 创建时间
     */
    private LocalDateTime createDate;

    /**
     * 更新
     */
    private LocalDateTime updateDate;

    /**
     * 删除标记
     */
    @TableLogic
    @JsonIgnore
    private String delFlag;

}
